local L = LibStub("AceLocale-3.0"):GetLocale("SDA")

local function BWarning()
	SendChatMessage(L["{Skull} Drums of Battle out in 2! {Skull}"], "PARTY")
end

local function OnUpdate(self, elapsed)
	if self.endtime and GetTime() > self.endtime then
		self.endtime = nil
		self:Hide()
		BWarning()
	end
end

local function OnEvent(self, event, unit, spell)
	if not UnitInParty("party1") then return end
	if unit == "player" then
		if spell == L["Drums of Battle"] then
			SendChatMessage(L["{circle} Drums of Battle used {circle}"], "PARTY")
			self.endtime = GetTime() + 28
			self:Show()
		elseif spell == L["Drums of War"] then
			SendChatMessage(L["{star} Drums of War used {star}"], "PARTY")
		elseif spell == L["Drums of Restoration"] then
			SendChatMessage(L["{triangle} Drums of Restoration used {triangle}"], "PARTY")
		elseif spell == L["Drums of Speed"] then
			SendChatMessage(L["{diamond} Drums of Speed used {diamond}"], "PARTY")
		elseif spell == L["Drums of Great Battle"] then
			SendChatMessage(L["{circle} Drums of Great Battle used {circle}"], "PARTY")
		elseif spell == L["Drums of Dark War"] then
			SendChatMessage(L["{star} Drums of Dark War used {star}"], "PARTY")
		elseif spell == L["Drums of Major Restoration"] then
			SendChatMessage(L["{triangle} Drums of Major Restoration used {triangle}"], "PARTY")
		elseif spell == L["Drums of Precision"] then
			SendChatMessage(L["{square} Drums of Precision used {square}"], "PARTY")
		end
	end
end

local SDA = CreateFrame("Frame")
SDA:Hide()
SDA:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
SDA:SetScript("OnEvent", OnEvent)
SDA:SetScript("OnUpdate", OnUpdate)